#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.3.6.1
 Author:         makrio.at

 Script Function:
	all getter functions

#ce ----------------------------------------------------------------------------

;////// GETTERS ////////////////////////////////////////////////////
Func getListViewLineColor()
  if $ListViewLineColorAkt = $ListViewLineColor1 Then
    $ListViewLineColorAkt = $ListViewLineColor2
  Else
    $ListViewLineColorAkt = $ListViewLineColor1
  EndIf
  Return $ListViewLineColorAkt
EndFunc

Func getSourceIP($data)
$data = $data[3]
Local $src=Number(BinaryMid ($data, 27 ,1))&"."&Number(BinaryMid ($data, 28 ,1))&"."&Number(BinaryMid ($data, 29 ,1))&"."&Number(BinaryMid ($data, 30 ,1))
Return $src
EndFunc ; ==> getSourceIP()

Func getSourcePort($data)
  $data = $data[3]
  Local $srcport=Number(BinaryMid ($data, 35 ,1))*256+Number(BinaryMid ($data, 36 ,1))
  Return $srcport
EndFunc ; ==> getSourcePort()

Func getDestIP($data)
  Local $dst=Number(BinaryMid ($data, 31 ,1))&"."&Number(BinaryMid ($data, 32 ,1))&"."&Number(BinaryMid ($data, 33 ,1))&"."&Number(BinaryMid ($data, 34 ,1))
  Return $dst
EndFunc ; ==> getDestIP()

Func getDestPort($data)
  $data = $data[3]
  Local $dstport=Number(BinaryMid ($data, 37 ,1))*256+Number(BinaryMid ($data, 38 ,1))
  Return $dstport
EndFunc ; ==> getDestPort()

Func getProtocol($data)
  $data = $data[3]
  Switch BinaryMid ($data, 24 ,1)
    Case "0x01"
     return "ICMP"
    Case "0x02"
     return "IGMP"
    Case "0x06"
      Local $flags=BinaryMid ($data, 48 ,1)
      Local $f=""
      If BitAND($flags,0x01) Then $f="Fin "
      If BitAND($flags,0x02) Then $f&="Syn "
      If BitAND($flags,0x04) Then $f&="Rst "
      If BitAND($flags,0x08) Then $f&="Psh "
      If BitAND($flags,0x10) Then $f&="Ack "
      If BitAND($flags,0x20) Then $f&="Urg "
      If BitAND($flags,0x40) Then $f&="Ecn "
      If BitAND($flags,0x80) Then $f&="Cwr "
      $f=StringTrimRight(StringReplace($f," ",","),1)
      return "TCP("&$f&")"
    Case "0x11"
      return "UDP"
    Case Else
      return "IP "
  EndSwitch
EndFunc ; ==> getProtocol()

Func getLen($data)
  return $data[2]
EndFunc ; ==> getLen()

Func getBody($data)
$body = _UTF8Decode(_HexToString($data[3]))
$begin = StringInStr($body, "<body ") +6
$message = StringRight($body,$data[2] - $begin)
Return $message
EndFunc ; ==> getBody()

Func getFrom($data)
  $body = _HexToString($data[3])
  $begin = StringInStr($body, "playername=") + 11
  $message = StringRight($body,$data[2] - $begin)
  $end = StringInStr($message, '"') -1
  $name = StringLeft($message, $end)
  Return $name
EndFunc ; ==> getFrom()

Func getMessage($data)
  $body = _UTF8Decode(_HexToString($data[3]))
  $begin = StringInStr($body, "<body>") + 5
  $message = StringRight($body,StringLen($body) - $begin)
  $end = StringInStr($message, '</body>') -1
  $text = StringLeft($message, $end)

  if StringLeft($text,1) = ">" then
    $text = StringTrimLeft($text, 1)
  ElseIf StringLeft($text, 2) = "y>" Then
    $text = StringTrimLeft($text, 2)
  ElseIf StringLeft($text, 3) = "dy>" Then
    $text = StringTrimLeft($text, 3)
  ElseIf StringLeft($text, 3) = "ody>" Then
    $text = StringTrimLeft($text, 4)
  EndIf
  Return $text
EndFunc ; ==> getMessage()

Func isTradeChat($data)
    $body = _UTF8Decode(_HexToString($data[3]))
    if StringInStr($body, "trade@conference") > 1 Then Return True
    Return False
EndFunc ; ==> isTradeChat

Func getKurs($text)
  $kurs = ""
  $ohneleerzeichen = StringReplace($text, " ", "")

  $regex = "[0-9]+(?:\.[0-9]*)?:[0-9]+(?:\.[0-9]*)?"
  $zahl =  StringRegExp($ohneleerzeichen, $regex, 1)
  if not @error Then
    $kurs = $zahl[0]
  EndIf
  return $kurs
EndFunc ;==> getKurs()

Func getWert($text)
  $regex = "[0-9]+(?:\.[0-9]*)?"
  $zahl = StringRegExp($text, $regex, 1)
  if not @error Then
    $zahl = $zahl[0]
  EndIf
  return $zahl
EndFunc ; ==> getWert